<?php

namespace App\Http\Controllers;

use App\Http\Response;
use App\Order;
use App\Repository\OrderRepository;
use App\Repository\wordRepository;
use Illuminate\Http\Request;

class OrderController extends OrderRepository
{

    /**
     * @param Request $request
     * @return Response
     */
    public function index(Request $request)
    {
        $range = $request->input('range', 10);
        $offset = $request->input('offset', 0);
        $params = $request->input('params', []);
        return Response::success($this->indexOrder($offset, $range, $params));
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return Response
     */
    public function store(Request $request)
    {
        $data = $request->input();
        return Response::success($this->storeOrder($data));
    }

    /**
     * @param int $id
     * @return Response
     */
    public function show(int $id)
    {
        return Response::success($this->getOrder($id));
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Order  $order
     * @return \Illuminate\Http\Response
     */
    public function edit(Order $order)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Order  $order
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, int $id)
    {
        return Response::success($this->updateOrder($id, $request->input()));
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
    public function destroy(int $id)
    {
        return Response::success($this->destroyOrder($id));
    }
}
